<?php

namespace App\Models;

class EnterLog extends Model
{
    protected $fillable = [
        'field_name',
    ];
    protected $table = 'enter_log';
    protected $certificateType = [1=>'身份证',2=>'永久居住证',3=>'护照'];
    public function user()
    {
        return $this->hasOne(AppUser::class,'id','user_id');
    }
    public function housings()
    {
        return $this->hasOne(Housings::class,'id','housings_id')->select('id','housings_num','hou_address');
    }

    public function housingsorder()
    {
        return $this->hasOne(HousingsOrder::class,'id','housings_order_id');
    }
    public function getCertificateTypeAttribute($value)
    {
        return isset($this->certificateType[$value]) ? $this->certificateType[$value] : reset($this->certificateType);
    }
}
